package cn.lyn4ever.common;

import io.swagger.annotations.ApiModel;

import java.util.HashMap;

@ApiModel
public class R extends HashMap<String,Object> {


    private R() {
    }

    public static R ok(){
        R r = new R();
        r.setCode("200");
        return r;
    }
    public static R ok(String msg){
        R r = new R();
        r.setCode("200");
        r.setMsg(msg);
        return r;
    }
    public static R error(){
        R r = new R();
        r.setCode("500");
        return r;
    }

    public static R error(String msg){
        R r = new R();
        r.setCode("500");
        r.setMsg(msg);
        return r;
    }

    public static R other(String code,String msg){
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public String getCode() {
        return (String) this.get("code");
    }

    public R setCode(String code) {
        this.put("code", code);
        return this;
    }

    public String getMsg() {
        return (String) this.get("msg");

    }

    public R setMsg(String msg) {
        this.put("msg", msg);
        return this;
    }

    @Override
    public R put(String key,Object value){
        super.put(key,value);
        return this;
    }

}

